package com.mxl.controller;

import com.mxl.model.UserModel;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author MXL
 * @date 2021/9/16 0016
 **/
@RestController
public class HelloController {

    @Operation(summary = "查询单个用户", description = "根据id查询单个用户")
    @Parameters({
            @Parameter(name = "id", description = "用户id", example = "654")
    })
    @RequestMapping("/user/{id}")
    public Object getUserById(@PathVariable Integer id) {
        return "getUserById(): ->" + id;
    }

    @Operation(summary = "新增用户", description = "新增用户2")
    @Parameter(name = "user")
    @RequestMapping("/user")
    public Object insertUser(@RequestBody UserModel user) {
        return "新增用户成功!";
    }

    @Value("${server.port}")
    private Integer port;

    @RequestMapping("/sayHello")
    public Object sayHello() {
        return "HelloController -> sayHello() -> port: " + port;
    }


}
